<% include header %>
<div id="nav">
    <nav class="container nav-header">
        <div class="text-center">
            <span class="glyphicon glyphicon-chevron-left back"></span>
            <span class="title"><%= title %></span>
            <span class="glyphicon glyphicon-home home"></span>
        </div>
    </nav>
</div>

<div class="container">
    <div class="askDetail">
        <h4 class="askTitle">提问标题:<%= ask.askTitle %></h4>
        <div class="askContent">
            <!--提问的编辑和删除-->
            <p>
                <% if(user && (user.name == ask.name)){ %>
                <a class="btn btn-default btn-edit"
                   href="/askEdit/<%= ask.name %>/<%= ask.time.second %>/<%= ask.askTitle %>">编辑</a>&#x3000
                <a class="btn btn-default btn-delete">删除</a>
                <% } %>
            </p>
            <!--提问详情展示-->
            <p>
                <span>提问人:<%= ask.name %></span>&#x3000
                <img src="/uploads/<%= ask.picUrl %>" alt="" class="askImg" onerror="this.src='/uploads/default.jpg'">&#x3000
                <span>提问时间:<%= ask.time.second %></span>&#x3000
                <span>浏览量: <%= ask.pv %></span>&#x3000
            </p>
            <h4>问题详情</h4>
            <p><%- ask.askContent %></p>
        </div>
    </div>

</div>
<% include answer %>
<% include footer %>
<script>
    $(function () {
        //点击删除按钮的时候给予用户提示 是否确定删除
        $('.btn-delete').click(function () {
            var r = confirm('确认删除吗?');
            if (r) {
                window.location = "/askDelete/<%= ask.name %>/<%= ask.time.second %>/<%= ask.askTitle %>";
            }
        });
        //没有人评论的时候,给于用户提示
        var length = '<%= ask.answers.length %>';
        console.log(length);
        if (length == 0) {
            $('.answerEmpty').css('display', 'block');
        } else {
            $('.answerEmpty').css('display', 'none');
        }

    })
</script>
